package com.okami.domain.school;

import com.okami.common.AbstractEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.persistence.*;
import java.util.Set;

/**
 * @author: TanJingyu
 * @create: 2020-12-19 15:06
 **/
@EqualsAndHashCode(callSuper = true)
@Data
@Entity
@Table
@Accessors(chain = true)
public class Student extends AbstractEntity<Long> {
    private String name;
    private Integer age;

    @ManyToMany(targetEntity = Course.class, cascade = CascadeType.PERSIST)
    @JoinTable(name = "student_course",
            joinColumns = {@JoinColumn(name = "student_id")},
            inverseJoinColumns = {@JoinColumn(name = "course_id")})
    private Set<Course> courses;
}
